string PHP_url = "http://mudhoneydesigns.com/customer_remove.php"; // replace the entire URL address


key owner = NULL_KEY;
integer listen_num = -1;
key http_request_id;
string first_name = "";
string last_name = "";
key toucher = NULL_KEY;
string toucher_name = "";
//================================================= 
string get_slurl()
{
    vector pos = llGetPos();
    string region_string = llEscapeURL(llGetRegionName());
    
    string result = "(http://slurl.com/secondlife/"+region_string+"/"+(string)((integer)pos.x)+"/"+(string)((integer)pos.y)+"/"+(string)((integer)pos.z)+")";

    return result;
}                   
//================================================= 
default
{
    state_entry()
    {
        toucher = NULL_KEY;
        first_name = "";
        last_name = "";
        owner = llGetOwner();
    }
    touch_start(integer total_number)
    {
        toucher_name = llDetectedName(0);
        toucher = llDetectedKey(0);
        
        list temp_list = llParseStringKeepNulls(toucher_name, [" "], []);    
        first_name = llList2String(temp_list, 0);
        last_name = llList2String(temp_list, 1);
        
        integer menu_chan = 0 - (integer)llFrand(2147483647);         
        listen_num  = llListen(menu_chan,"", toucher,"");                
        llDialog(toucher, "
        
By pressing [ Agree ], you agree to remove your self from the MudHoney Designs mailing list.

==========================", ["Agree","Not Agree"], menu_chan); // You can change the menu message
        llSetTimerEvent(60.0);
    }
    listen(integer channel, string name, key id, string message) 
    {
        llListenRemove(listen_num);
        if (message == "Agree")
        {
            state register;
        }
        else if (message == "Not Agree")
            llSay(0,"  thank you.");
    }    
    timer()
    {
        llListenRemove(listen_num);
        llSetTimerEvent(0.0);
    }    
}
state register
{
    state_entry()
    {
        llSay(0,"  checking your registration status ...");        
        
        string http_body = llEscapeURL("customer_key") +"="+ llEscapeURL((string)toucher) +"&"+ llEscapeURL("first_name") +"="+ llEscapeURL(first_name) +"&"+ llEscapeURL("last_name") +"="+ llEscapeURL(last_name);            

        http_request_id = llHTTPRequest(PHP_url, [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"], http_body);
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == http_request_id)
        {        
            if (body == "key_not_in_list")
            {
                llSay(0,"  Member name not found. Already unsubscribed?");
            }    
            else if (body == "key_removed")
            {
                llSay(0,"  thank you "+toucher_name+", your request has been sent.  You will be removed from the list.  Have a nice day!");
                llInstantMessage(owner,"  register [ "+toucher_name+" ] successful from PHP.  "+get_slurl());
            }
            else
            {
//                llSay(0,"  sorry, unable to access to database.  Please try again later.");
                llSay(0,"  thank you "+toucher_name+", your request has been sent. Member not found in DB, Already unsubscribed?");
//                llInstantMessage(owner,"  register [ "+toucher_name+" ] backup from web host server not available.  "+get_slurl());
            }                 
        }
        state default;
    }             
}